<template>
	<view class="page">
		<view class="user">
			<view class="info">
				<view class="position">
					{{info.power}}
				</view>
				<view class="name">
					{{info.name}}
				</view>
			</view>
			<view>
				<button class="btn" type="default" @click="onlogout">
					退出登录
				</button>
			</view>
		</view>
		<!-- 权限 -->
		<view>
			<button @click="showModel">短信权限设置</button>
			<button @click="navTo('/pages/index/logData')">群发记录</button>
			<button @click="navTo('/pages/index/send')">群发</button>
		</view>
	</view>
</template>

<script>
	import permision from "@/js_sdk/wa-permission/permission.js"
	export default {
		components: {},
		data() {
			return {
				info: {
					img: "../../static/logo.png",
					power: "维修人员",
					name: "陈晓明"
				},
			}
		},
		onLoad() {
			this.info = this.getInfo();
		},
		methods: {
			showModel(){
				var that = this;
				uni.showModal({
				    title: '提示',
				    content: '权限管理 -> 发送短信 -> 始终允许',
				    success: function (res) {
				        if (res.confirm) {
				            that.gotoAppPermissionSetting()
				        }
				    }
				});
			},
			gotoAppPermissionSetting: function() {
				permision.gotoAppPermissionSetting()
			},
			async requestAndroidPermission(permisionID) {
				var result = await permision.requestAndroidPermission(permisionID)
				var strStatus
				if (result == 1) {
					strStatus = "已获得授权"
				} else if (result == 0) {
					strStatus = "未获得授权"
				} else {
					strStatus = "被永久拒绝权限"
				}
				uni.showModal({
					content: permisionID + strStatus,
					showCancel: false
				});
			},
			onlogout(){
				console.log("退出");
				// uni.clearStorageSync();
				uni.reLaunch({
					url: "/pages/login/login"
				})
			}
		}
	}
</script>

<style lang="scss">
	button {
		margin: 15px;
		color: #007AFF;
	}

	.user {
		height: 340rpx;
		background-color: #3291F8;
		color: #fff;
		display: flex;
		justify-content: space-around;
		align-items: center;

		.img {
			width: 200rpx;
			height: 200rpx;
			border-radius: 50%;
			overflow: hidden;

			// background-color: #fff;
			image {
				width: 100%;
				height: 100%;
			}
		}

		.info {
			width: 25%;

			.position {
				font-size: 28rpx;
			}

			.name {
				font-size: 40rpx;
			}
		}

		.btn {
			background-color: #FFC300;
			height: 88rpx;
			line-height: 88rpx;
			border-radius: 88rpx;
			font-size: 32rpx;
			color: #fff;
			padding: 0 50rpx;
		}
	}
</style>
